﻿<UserControl x:Class="AutoLoL.Controls.BuildsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="clr-namespace:AutoLoL.Controls"
             xmlns:converters="clr-namespace:AutoLoL.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <UserControl.Resources>
        <converters:MasteryBuildToIntConverter x:Key="MasteryBuildToIntConverter" />
        <converters:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter" />
        <converters:SummonerSpellToVisibilityConverter x:Key="SummonerSpellToVisibilityConverter" />
    </UserControl.Resources>
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Top">
            <StackPanel Orientation="Horizontal" Margin="0 0 0 10" DockPanel.Dock="Top">
                <Button Width="75" Height="23" HorizontalContentAlignment="Left" Click="CreateButton_Click">
                    <Button.Content>
                        <StackPanel Orientation="Horizontal">
                            <Image Height="16" Width="16" Source="pack://siteoforigin:,,,/Data/Images/Icons/document.png" />
                            <TextBlock Margin="5 0 0 0" Text="Create" />
                        </StackPanel>
                    </Button.Content>
                </Button>
                <Button Width="75" Height="23" Name="EditButton" HorizontalContentAlignment="Left" Click="EditButton_Click" Margin="10 0 0 0">
                    <Button.Content>
                        <StackPanel Orientation="Horizontal">
                            <Image Height="16" Width="16" Source="pack://siteoforigin:,,,/Data/Images/Icons/pencil.png" />
                            <TextBlock Margin="5 0 0 0" Text="Edit" />
                        </StackPanel>
                    </Button.Content>
                </Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0 0 0 10">
                <Border BorderBrush="DimGray" BorderThickness="1" DockPanel.Dock="Left">
                    <Grid MouseDown="ChampionGrid_MouseDown" Background="#22FFFFFF" Cursor="Hand" ToolTip="Click to select a champion">
                        <Image Height="60" Width="60" Source="pack://siteoforigin:,,,/Data/Images/Icons/random.png" />
                        <Image Name="ChampionImage" Width="60" Height="60" />
                    </Grid>
                </Border>
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Bottom" Margin="10 0 0 0">
                    <Image Height="16" Width="16" Source="pack://siteoforigin:,,,/Data/Images/Icons/magnifier.png" />
                    <TextBlock Margin="5 0 0 0" Text="Filter:" VerticalAlignment="Center" />
                    <TextBox Width="150" Name="FilterTextBox" KeyDown="FilterTextBox_KeyDown" Margin="5 0 0 0" TextChanged="FilterTextBox_TextChanged" />
                </StackPanel>
            </StackPanel>
        </StackPanel>
        <DataGrid Name="BuildsDataGrid" RowHeaderWidth="0" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" SelectionMode="Extended"  SelectionUnit="FullRow" AutoGenerateColumns="False" MouseDoubleClick="BuildsDataGrid_MouseDoubleClick">
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Deploy Items" Click="MenuItemDeploy_Click" ToolTip="Deploy items for all selected builds."/>
                    <MenuItem Header="Edit" Click="MenuItemEdit_Click">
                        <MenuItem.Icon>
                            <Image Source="pack://siteoforigin:,,,/Data/Images/Icons/pencil.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Delete" Click="MenuItemDelete_Click">
                        <MenuItem.Icon>
                            <Image Source="pack://siteoforigin:,,,/Data/Images/Icons/trash.gif" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.RowStyle>
                <Style TargetType="{x:Type DataGridRow}">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True" >
                            <Setter Property="Background" Value="#FF3399FF" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.RowStyle>
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="" Width="38">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="32" Height="32" Source="{Binding Path=Champion.IconBitmapImage}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Title" Width="*" Binding="{Binding Title}" IsReadOnly="True" FontSize="13" Selector.IsSelected="True" />
                <DataGridTemplateColumn Header="Masteries" Width="124">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="2 0 0 0">
                                <Grid Width="44">
                                    <Image Height="18" Width="18" Source="pack://siteoforigin:,,,/Data/Images/Icons/offense.png" HorizontalAlignment="Left" />
                                    <TextBlock Text="{Binding Path=MasteryBuild, Converter={StaticResource MasteryBuildToIntConverter}, ConverterParameter='0,14'}" FontSize="14" VerticalAlignment="Center" Margin="0 0 8 0" HorizontalAlignment="Right" />
                                </Grid>
                                <Grid Width="36">
                                    <Image Height="18" Width="18" Source="pack://siteoforigin:,,,/Data/Images/Icons/defense.png" HorizontalAlignment="Left" />
                                    <TextBlock Text="{Binding Path=MasteryBuild, Converter={StaticResource MasteryBuildToIntConverter}, ConverterParameter='14,14'}" FontSize="14" VerticalAlignment="Center" Margin="0 0 4 0" HorizontalAlignment="Right" />
                                </Grid>
                                <Grid Width="40">
                                    <Image Height="18" Width="18" Source="pack://siteoforigin:,,,/Data/Images/Icons/utility.png" HorizontalAlignment="Left" />
                                    <TextBlock Text="{Binding Path=MasteryBuild, Converter={StaticResource MasteryBuildToIntConverter}, ConverterParameter='28,15'}" FontSize="14" VerticalAlignment="Center" Margin="0 0 4 0" HorizontalAlignment="Right" />
                                </Grid>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Spells" Width="80">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                <Grid Background="#22000000" Height="28" Width="28">
                                    <Image Source="{Binding Path=SummonerSpells[0].IconBitmapImage}" />
                                    <Rectangle Fill="#88FFFFFF">
                                        <Rectangle.Visibility>
                                            <MultiBinding Converter="{StaticResource SummonerSpellToVisibilityConverter}" ConverterParameter="True">
                                                <Binding Path="SummonerSpells[0]" />
                                                <Binding Path="MasteryBuild.ImprovedSummonerSpells" />
                                            </MultiBinding>
                                        </Rectangle.Visibility>
                                    </Rectangle>
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=SummonerSpells[1].IconBitmapImage}" />
                                    <Rectangle Fill="#88FFFFFF">
                                        <Rectangle.Visibility>
                                            <MultiBinding Converter="{StaticResource SummonerSpellToVisibilityConverter}" ConverterParameter="True">
                                                <Binding Path="SummonerSpells[1]" />
                                                <Binding Path="MasteryBuild.ImprovedSummonerSpells" />
                                            </MultiBinding>
                                        </Rectangle.Visibility>
                                    </Rectangle>
                                </Grid>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Items" Width="200">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                <Grid Background="#22000000" Height="28" Width="28">
                                    <Image Source="{Binding Path=Items[0].IconBitmapImage}" />
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=Items[1].IconBitmapImage}" />
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=Items[2].IconBitmapImage}" />
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=Items[3].IconBitmapImage}" />
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=Items[4].IconBitmapImage}" />
                                </Grid>
                                <Grid Background="#22000000" Height="28" Width="28" Margin="5 0 0 0">
                                    <Image Source="{Binding Path=Items[5].IconBitmapImage}" />
                                </Grid>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Clicker" Width="50">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Height="28" Width="28" Click="QuickPlay_Click">
                                <Image Source="pack://siteoforigin:,,,/Data/Images/Icons/play.png"/>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
